package com.itheima.config;


import com.itheima.controller.ProjectInterceptor;
import com.itheima.controller.ProjectInterceptor2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
//@ComponentScan({"com.itheima.controller","com.itheima.config"})
@ComponentScan({"com.itheima.controller"})
@EnableWebMvc
public class SpringMvcConfig implements WebMvcConfigurer {
    @Autowired
    private ProjectInterceptor projectInterceptor;
    @Autowired
    private ProjectInterceptor2 projectInterceptor2;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置多拦截器 (先配置的先运行)
        registry.addInterceptor(projectInterceptor).addPathPatterns("/books","/books/*");

        registry.addInterceptor(projectInterceptor2).addPathPatterns("/books","/books/*");
    }

}